package com.lnsoft.util;

public class SqlUtil {
	/**
	 * 用于sql分页
	 * 
	 * @param sql
	 * @param pageSize
	 *            页的条数
	 * @param currentPage
	 *            当前第几页
	 * @return
	 */
	public static String sqlWithPage(String sql, int pageSize, int currentPage) {
		StringBuffer page = new StringBuffer();
		page.append("SELECT adam1.* FROM (SELECT adam0.*,rownum rn FROM (").append(sql + ") adam0")
				.append(" WHERE rownum<=" + (currentPage * pageSize) + ") adam1")
				.append(" WHERE adam1.rn>=" + ((currentPage - 1) * pageSize + 1));
		return page.toString();
	}
}
